import {getFilePathBaseUrl} from "@/config.js";

const myFilters = {
  imgPathFilter: function (img) {
    if(img==null||img==""){
      return "";
    }
    if (img.indexOf("https://") < 0 && img.indexOf("http://") < 0) {
      img = getFilePathBaseUrl() + img;
    }
    return img;
  },
  imgOriginalPathFilter: function (img) {
    if (img.indexOf("https://") < 0 && img.indexOf("http://") < 0) {
      img = getFilePathBaseUrl() + img;
    }
    return img;
  },
  filePathFilter: function (path) {
    if (path.indexOf("https://") < 0 && path.indexOf("http://") < 0) {
      path = getFilePathBaseUrl() + path;
    }
    return path;
  },
  textNumFilter: function (text) {
    if (text.length > 30) {
      return text.slice(0, 30) + '...'
    }
    return text;
  },
  problemTextNumFilter: function (text) {
    if (text.length > 10) {
      return text.slice(0, 10) + '...'
    }
    return text;
  }
};
export default myFilters;


